package org.jeeasy.biz.mobile.mobile.manage;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.jeeasy.biz.mobile.modules.brand.domain.MbBrand;
import org.jeeasy.biz.mobile.modules.brand.service.MbBrandService;
import org.jeeasy.common.core.annotation.dict.DictTranslation;
import org.jeeasy.common.core.base.SimpleCurdController;
import org.jeeasy.common.core.domain.model.QueryPageModel;
import org.jeeasy.common.core.domain.vo.R;
import org.springframework.web.bind.annotation.*;


/**
 * @author AlpsDDJ
 * @date 2023/12/6
 */
@RestController
@Tag(name = "品牌")
@RequestMapping("/mb/brand")
public class BrandController extends SimpleCurdController<MbBrandService, MbBrand> {

    @GetMapping
    @DictTranslation
    @Operation(summary = "品牌列表", description = "品牌列表")
    public R<IPage<MbBrand>> list(QueryPageModel queryPageModel) {
        return R.ok(super.queryPage(queryPageModel));
    }

    @GetMapping("/{id}")
    @DictTranslation
    @Operation(summary = "根据ID查找品牌", description = "根据ID查找品牌")
    public R<MbBrand> info(@PathVariable("id") String id) {
        return R.ok(super.getById(id));
    }

    @PutMapping
    @Operation(summary = "编辑品牌", description = "编辑品牌")
    public R<Void> edit(@RequestBody MbBrand entity) {
        super.update(entity);
        return R.ok();
    }

    @PostMapping
    @Operation(summary = "添加品牌", description = "添加品牌")
    public R<Void> add(@RequestBody MbBrand entity) {
        super.insert(entity);
        return R.ok();
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "根据ID删除品牌", description = "根据ID删除品牌")
    public R<Void> remove(@PathVariable("id") String id) {
        super.deleteById(id);
        return R.ok();
    }

    @DeleteMapping("/batch")
    @Operation(summary = "批量删除品牌", description = "批量删除品牌")
    public R<Void> batchRemove(@RequestParam(name = "ids") String ids) {
        super.batchDelete(ids);
        return R.ok();
    }
}
